<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 86178
  Date: 2022/3/16
  Time: 18:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>仪表盘</title>
    <link rel="stylesheet" href="/webjars/bootstrap/4.6.1/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/css/layout.css">
</head>
<body>
<div class="head-body-container">
    <div class="head">
        <jsp:include page="header.jsp"></jsp:include>
    </div>
    <div class="aside-main-container">
        <div class="aside">
            <jsp:include page="aside.jsp"></jsp:include>
        </div>
        <div class="main">
            <form id="searchform" action="/dashboard" method="post">
                <div class="d-flex">
                    <input class="form-control" name="filename" placeholder="输入文件名"/>
                    <input id="pageNum" type="hidden" name="pageNum" value="1">
                    <input id="pageSize" type="hidden" name="pageSize" value="5">
                    <button class="btn-primary btn-sm" onclick="queryByCondition(1)" type="submit">查询</button>
                </div>
            </form>
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">数据库中的内容</div>

                <!-- Table -->
                <table class="table">
                    <thead>
                    <tr>
                        <th>id</th>
                        <th>用户名称</th>
                        <th>文件名</th>
                        <th>下载时间</th>
                        <th>下载所在盘符</th>
                        <th>是否下载成功</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${list}" var="list">
                        <tr>
                            <td>${list.downloadLogId}</td>
                            <td>${list.userName}</td>
                            <td>${list.fileName}</td>
                            <td>${list.downloadTime}</td>
                            <td>${list.targetFile}</td>
                            <td>${list.state}</td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <div class="btn-group-sm d-flex justify-content-center">
                    <div>共${total}条</div>
                    <c:forEach var="i" begin="1" end="${pages}" step="1">
                        <c:choose>
                            <c:when test="${i==param.pageNum}">
                                <button type="button" onclick="queryByCondition('${i}')"
                                        class="btn-warning">${i}</button>
                            </c:when>
                            <c:otherwise>
                                <button type="button" onclick="queryByCondition('${i}')"
                                        class="btn-warning">${i}</button>

                            </c:otherwise>
                        </c:choose>

                    </c:forEach>

                </div>

            </div>
        </div>
    </div>
</div>
<script>
    function queryByCondition(pageNum) {
        alert(" go  " + searchform);
        document.getElementById("pageNum").value = pageNum;
        document.getElementById("searchform").submit();
    }
</script>
</body>
</html>
